package org.example.myleet.p448;

import java.util.ArrayList;
import java.util.List;

public class Solution {
    /**
     * 4 ms
     * 使用hash的方式记录数字是否出现过
     */
    public List<Integer> findDisappearedNumbers(int[] nums) {
        int n = nums.length;
        int[] hash = new int[n+1];
        for (int i=0; i<n+1; i++) {
            hash[i] = 1;
        }
        for (int i=0; i<n; i++) {
            hash[nums[i]] = 0;
        }
        List<Integer> reply = new ArrayList<>();
        for (int i=1; i<n+1; i++) {
            if (hash[i] == 1) {
                reply.add(i);
            }
        }
        return reply;
    }
}
